import React from 'react'
import {BrowserRouter as Router , Route, Switch,Redirect} from 'react-router-dom';
import {LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import 'moment/locale/zh-cn';
import Error from '../other/error';
import Pages from '../pages';
import Main from '../pages/main';
import Login from '../other/login';
import Merchant from '../pages/merchant';
import Merchantadd from '../pages/merchant/add';
import Merchantmodify from '../pages/merchant/modify';
import Merchantdetails from '../pages/merchant/details';

import Table from '../pages/table';
import Tableadvance from '../pages/table/advancedTable';
import Tableasync from '../pages/table/asyncTable';
import Tablebasic from '../pages/table/basicTable';

const Routers = () => (
  <LocaleProvider locale={zhCN}>
    <Router>
      <Switch>
        <Route path='/'  exact   component = {Pages}/>
        <Route path='/main'  render = {()=> <Main>
          <Route path='/main/merchant' render = {() => <Merchant>
              <Route path='/main/merchant/Add'  component = {Merchantadd}/>
              <Route path='/main/merchant/Modify'  component = {Merchantmodify}/>
              <Route path='/main/merchant/Details'  component = {Merchantdetails}/>
          </Merchant>}/>
          <Route path='/main/table' render = {() => <Table>
              <Route path='/main/table/advance'  component = {Tableadvance}/>
              <Route path='/main/table/async'  component = {Tableasync}/>
              <Route path='/main/table/basic'  component = {Tablebasic}/>
          </Table>}/>
        </Main>}/>
        <Route path='/login' exact component = {Login}/>
        <Route component={Error} render={() => <Redirect to="/404" />}></Route>
      </Switch>
    </Router>
  </LocaleProvider>
)

export default Routers
